package com.haixinga.mvntemplate.ctrl;

import com.haixinga.mvntemplate.entity.SysUser;
import com.haixinga.mvntemplate.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author terrfly
 * @Date 2019/11/7 14:49
 * @Description 用户信息Ctrl
 **/
@RestController
@RequestMapping("/api/sysUser")
public class SysUserController {

    @Autowired
    private HttpServletRequest request;

    @Autowired
    private ISysUserService sysUserService;

    /** 查询用户列表 */
    @RequestMapping("/list")
    public Object list(){

        SysUser sysUser = new SysUser();
        sysUser.setUserName(request.getParameter("userName"));
        return sysUserService.list(sysUser);
    }

    @PostMapping("/add")
    public boolean add(){

        SysUser sysUser = new SysUser();
        sysUser.setUserName(request.getParameter("userName"));
        sysUser.setState(Byte.parseByte(request.getParameter("state")));
        return sysUserService.save(sysUser);
    }

}
